package com.example.skyline.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.skyline.entity.User;
import com.example.skyline.mapper.UserManagementMapper;
import com.example.skyline.service.UserManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserManagementMapper, User> implements UserManagementService {
    @Autowired
    private UserManagementMapper userManagementMapper;

    @Override
    public int addUser(User user) {
        return userManagementMapper.insert(user);
    }

    @Override
    public int deleteUser(Integer id) {
        return userManagementMapper.deleteById(id);
    }

    @Override
    public int updateUser(User user) {
        return userManagementMapper.updateById(user);
    }

    @Override
    public User getUserById(Integer id) {
        return userManagementMapper.selectById(id);
    }

    @Override
    public List<User> selectAll(String userName, String name, Integer start, Integer pageSize) {
        start=start-1;
        return userManagementMapper.selectAll(userName, name, start, pageSize);
    }

    @Override
    public int countAll(String userName, String name) {
        return userManagementMapper.countAll(userName, name);
    }


}
